// pages/find/find.js
const http = require("../../utils/http");
Page({

    /**
     * 页面的初始数据
     */
    data: {
        list: ["欧洲", "亚洲", "大洋洲", "非洲", "北美洲", "南美洲"],
        season:["春意阑珊","盛夏果实","秋来秋去","冬之恋曲"],
        country: [],
        // seasonData:[],
        isChecked1:true,
        isChecked2:false,
        userCellId: 0,
        continent:"欧洲",
        seasonList:"春意阑珊",
        inpttest:"",
        type:"jijie"
    },
    // 跳转到list页面
    goList(){
        wx:wx.navigateTo({
          url: '/pages/list/list?senceKey='+this.data.inpttest,
        })
    },
    serviceSelection1:function(){
        this.setData({isChecked1:true,isChecked2:false});
        this.getDataList();
    },
    serviceSelection2:function(){
        this.setData({isChecked2:true,isChecked1:false});
        this.getseasonList();
    },
    // 切换洲
    tryDriver:function(e) {
        console.log("点击了！");
        // 获取点击的元素的下标
        var index = e.currentTarget.dataset.index;
        var name = e.currentTarget.dataset.name;
        console.log(index,name);
        this.setData({userCellId:index});
        this.setData({continent:name});
        this.getDataList();
    },

    checkseen:function(e){
        console.log("点击了！");
        // 获取点击的元素的下标
        var index = e.currentTarget.dataset.index;
        var name = e.currentTarget.dataset.name;
        console.log(index,name);
        this.setData({userCellId:index});
        this.getseasonList();
    },
    // 获取数据
    getDataList(){
         // 获取洲数据
         http.request("requirement/destination/countries/"+this.data.continent, {}, "get").then(res => {
            console.log(res);
            console.log("requirement/destination/countries/"+this.data.continent);
            this.setData({country: res.data})
        });
    },
// 获取季节数据
    getseasonList(){
        http.request("requirement/request/getMatchedProducts",{
            product_type: 1,
            request_season: [this.data.seasonList]
        },"post").then(res=>{
            console.log(res);
            this.setData({country: res.data.matchedProducts});
        })
    },
    /**
     * 生命周期函数--监听页面加载
     */
    onLoad: function (options) {
      this.getDataList();
      this.getseasonList();
    },

    /**
     * 生命周期函数--监听页面初次渲染完成
     */
    onReady: function () {

    },

    /**
     * 生命周期函数--监听页面显示
     */
    onShow: function () {

    },

    /**
     * 生命周期函数--监听页面隐藏
     */
    onHide: function () {

    },

    /**
     * 生命周期函数--监听页面卸载
     */
    onUnload: function () {

    },

    /**
     * 页面相关事件处理函数--监听用户下拉动作
     */
    onPullDownRefresh: function () {

    },

    /**
     * 页面上拉触底事件的处理函数
     */
    onReachBottom: function () {

    },

    /**
     * 用户点击右上角分享
     */
    onShareAppMessage: function () {

    }
})